package com.example.lsq.controller;

import com.example.lsq.entity.User;
import com.example.lsq.service.UserService;
import com.example.lsq.util.Result;
import com.example.lsq.util.Resultsubmit;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.Map;

@RestController
@RequestMapping
public class UserController {
    @Resource
    private UserService userService;

    @RequestMapping(value = "/login",method = RequestMethod.POST)
    public Result login(@RequestBody Map<String,String>map, HttpServletRequest request) {
        String userId = map.get("userId");
        String password = map.get("Password");
        if(userId==null || password==null ||userId.isEmpty() || password.equals("")) {
            return Resultsubmit.error("登录失败，参数不全");

        }
        return userService.login(userId,password,request);
        }
}
